package com.qunarmei.socketio;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import java.util.UUID;

public class MyServerHandler extends SimpleChannelInboundHandler<String>{

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        cause.printStackTrace();
        ctx.close();
    }

    @Override
    protected void messageReceived(ChannelHandlerContext ctx, String msg) throws Exception {
        //打印出客户端地址


        System.out.println(ctx.channel().remoteAddress()+", "+msg);


        ctx.channel().writeAndFlush("form server: "+ UUID.randomUUID());
    }
}
